package ar.edu.phm.tp.cuatro.planificacionDsl.serializer;

import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Asignacion;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Aula;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Dia;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Docente;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Exclusiva;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Materia;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Model;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Plan;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.PlanificacionPackage;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Semi;
import ar.edu.phm.tp.cuatro.planificacionDsl.planificacion.Simple;
import ar.edu.phm.tp.cuatro.planificacionDsl.services.PlanificacionGrammarAccess;
import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

@SuppressWarnings("all")
public class PlanificacionSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private PlanificacionGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == PlanificacionPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case PlanificacionPackage.ASIGNACION:
				if(context == grammarAccess.getAsignacionRule()) {
					sequence_Asignacion(context, (Asignacion) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.AULA:
				if(context == grammarAccess.getAulaRule() ||
				   context == grammarAccess.getEntidadRule()) {
					sequence_Aula(context, (Aula) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.DIA:
				if(context == grammarAccess.getDiaRule()) {
					sequence_Dia(context, (Dia) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.DOCENTE:
				if(context == grammarAccess.getDocenteRule() ||
				   context == grammarAccess.getEntidadRule()) {
					sequence_Docente(context, (Docente) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.EXCLUSIVA:
				if(context == grammarAccess.getExclusivaRule()) {
					sequence_Exclusiva(context, (Exclusiva) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.MATERIA:
				if(context == grammarAccess.getEntidadRule() ||
				   context == grammarAccess.getMateriaRule()) {
					sequence_Materia(context, (Materia) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.MODEL:
				if(context == grammarAccess.getModelRule()) {
					sequence_Model(context, (Model) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.PLAN:
				if(context == grammarAccess.getEntidadRule() ||
				   context == grammarAccess.getPlanRule()) {
					sequence_Plan(context, (Plan) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.SEMI:
				if(context == grammarAccess.getSemiRule()) {
					sequence_Semi(context, (Semi) semanticObject); 
					return; 
				}
				else break;
			case PlanificacionPackage.SIMPLE:
				if(context == grammarAccess.getSimpleRule()) {
					sequence_Simple(context, (Simple) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (materia=[Materia|ID] aula=[Aula|ID] horaInicio=INT horaFin=INT)
	 */
	protected void sequence_Asignacion(EObject context, Asignacion semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.ASIGNACION__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.ASIGNACION__MATERIA));
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.ASIGNACION__AULA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.ASIGNACION__AULA));
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.ASIGNACION__HORA_INICIO) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.ASIGNACION__HORA_INICIO));
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.ASIGNACION__HORA_FIN) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.ASIGNACION__HORA_FIN));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getAsignacionAccess().getMateriaMateriaIDTerminalRuleCall_1_0_1(), semanticObject.getMateria());
		feeder.accept(grammarAccess.getAsignacionAccess().getAulaAulaIDTerminalRuleCall_3_0_1(), semanticObject.getAula());
		feeder.accept(grammarAccess.getAsignacionAccess().getHoraInicioINTTerminalRuleCall_5_0(), semanticObject.getHoraInicio());
		feeder.accept(grammarAccess.getAsignacionAccess().getHoraFinINTTerminalRuleCall_7_0(), semanticObject.getHoraFin());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID (recursos+=TipoRecurso recursos+=TipoRecurso*)?)
	 */
	protected void sequence_Aula(EObject context, Aula semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (dia=NombreDia asignaciones+=Asignacion*)
	 */
	protected void sequence_Dia(EObject context, Dia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID (tipo=Simple | tipo=Semi | tipo=Exclusiva) materias+=[Materia|ID]*)
	 */
	protected void sequence_Docente(EObject context, Docente semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     nombre='Exclusiva'
	 */
	protected void sequence_Exclusiva(EObject context, Exclusiva semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.EXCLUSIVA__NOMBRE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.EXCLUSIVA__NOMBRE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getExclusivaAccess().getNombreExclusivaKeyword_0(), semanticObject.getNombre());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID horas=INT dias=INT (requisitos+=TipoRecurso requisitos+=TipoRecurso*)?)
	 */
	protected void sequence_Materia(EObject context, Materia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     entidades+=Entidad*
	 */
	protected void sequence_Model(EObject context, Model semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (anio=INT cuatrimestre=Cuatrimestre materiasADictar+=[Materia|ID] materiasADictar+=[Materia|ID]* dias+=Dia*)
	 */
	protected void sequence_Plan(EObject context, Plan semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     nombre='Semi'
	 */
	protected void sequence_Semi(EObject context, Semi semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.SEMI__NOMBRE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.SEMI__NOMBRE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getSemiAccess().getNombreSemiKeyword_0(), semanticObject.getNombre());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     nombre='Simple'
	 */
	protected void sequence_Simple(EObject context, Simple semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificacionPackage.Literals.SIMPLE__NOMBRE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificacionPackage.Literals.SIMPLE__NOMBRE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getSimpleAccess().getNombreSimpleKeyword_0(), semanticObject.getNombre());
		feeder.finish();
	}
}
